import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import {rules} from '/@/utils/helper/validator';
import {render} from '/@/utils/common/renderUtils';
import {getWeekMonthQuarterYear} from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
	{
		title: '充电站名称',
		align: 'center',
		dataIndex: 'stationName',
		slots: {customRender: 'name'},
	},
	{
		title: '所属省市',
		align: 'center',
		dataIndex: 'areaArray',
	},
	{
		title: '站类型',
		align: 'center',
		dataIndex: 'stationType_dictText',
	},
	{
		title: '所属运营商',
		align: 'center',
		dataIndex: 'operatorId_dictText',
	},
	{
		title: '站地址',
		align: 'center',
		dataIndex: 'stationAddr',
	},
	{
		title: '站状态',
		align: 'center',
		dataIndex: 'stationStatus_dictText',
		slots: {customRender: 'stationStatus_dictText'},
	},
	{
		title: '装机功率（千瓦）',
		align: 'center',
		dataIndex: 'totalPower',
	},
	{
		title: '直流桩数',
		align: 'center',
		dataIndex: 'dcChargers',
		slots: {customRender: 'dcChargers'},
	},
	{
		title: '交流桩数',
		align: 'center',
		dataIndex: 'acChargers',
		slots: {customRender: 'acChargers'},
	},
	{
		title: '建档日期',
		align: 'center',
		dataIndex: 'createTime',
		customRender: ({text}) => {
			text = !text ? '' : text.length > 10 ? text.substr(0, 10) : text;
			return text;
		},
	},
	//  {
	//   title: '经度',
	//   align:"center",
	//   dataIndex: 'longitude'
	//  },
	//  {
	//   title: '纬度',
	//   align:"center",
	//   dataIndex: 'latitude'
	//  },
	//  {
	//   title: '删除状态',
	//   align:"center",
	//   dataIndex: 'isDeleted_dictText'
	//  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
		label: '充电站名称',
		field: 'stationName',
		component: 'Input',
		//colProps: {span: 6},
	},
	{
		label: '站类型',
		field: 'stationType',
		component: 'JDictSelectTag',
		componentProps: {
			dictCode: 'stationType',
		},
		//colProps: {span: 6},
	},
	{
		label: '所属运营商',
		field: 'operatorId',
		component: 'Select',
		slot: 'operatorIdSlot',
	},
	{
		label: '所属省市',
		field: 'areaArray',
		component: 'JAreaLinkage',
		componentProps: {},
		//colProps: {span: 6},
	},

	{
		label: '站状态',
		field: 'status',
		component: 'JDictSelectTag',
		componentProps: {
			dictCode: 'cdzzt',
		},
		//colProps: {span: 6},
	},
	{
		label: '删除状态',
		field: 'isDeleted',
		component: 'JDictSelectTag',
		componentProps: {
			dictCode: 'isdelet',
		},
		//colProps: {span: 6},
	},
];
//表单数据
export const formSchema: FormSchema[] = [
	{
		label: '充电站名称',
		field: 'stationName',
		component: 'Input',
		dynamicRules: ({model, schema}) => {
			return [{required: true, message: '请输入充电站名称!'}];
		},
	},
	{
		label: '站类型',
		field: 'stationType',
		component: 'JDictSelectTag',
		componentProps: {
			dictCode: 'stationType',
			// stringToNumber: true,
		},
		dynamicRules: ({model, schema}) => {
			return [{required: true, message: '请输入站类型!'}];
		},
	},
	{
		label: '所属运营商',
		field: 'operatorId',
		component: 'Select',
		slot: 'operatorIdSlot1',
		dynamicRules: ({model, schema}) => {
			return [{required: true, message: '请输入所属运营商!'}];
		},
	},
	{
		label: '站地址',
		field: 'stationAddr',
		component: 'Input',
		dynamicRules: ({model, schema}) => {
			return [{required: true, message: '请输入站地址!'}];
		},
	},
	{
		label: '站状态',
		field: 'stationStatus',
		component: 'JDictSelectTag',
		componentProps: {
			dictCode: 'cdzzt',
			stringToNumber: true,
		},
		dynamicRules: ({model, schema}) => {
			return [{required: true, message: '请输入站状态!'}];
		},
	},
	{
		label: '直流桩数',
		field: 'dcChargers',
		component: 'InputNumber',
	},
	{
		label: '交流桩数',
		field: 'acChargers',
		component: 'InputNumber',
	},
	{
		label: '建档日期',
		field: 'createTime',
		component: 'DatePicker',
	},

	{
		label: '地图选点',
		field: 'dituxuandian',
		component: 'Select',
		slot: 'dituxuandian',
	},
	{
		label: '经度',
		field: 'stationLng',
		component: 'InputNumber',
		dynamicRules: ({model, schema}) => {
			return [{required: true, message: '请输入经度!'}];
		},
	},
	{
		label: '纬度',
		field: 'stationLat',
		component: 'InputNumber',
		dynamicRules: ({model, schema}) => {
			return [{required: true, message: '请输入纬度!'}];
		},
	},
	// {
	//   label: '删除状态（0:未删除, 1:已删除）',
	//   field: 'isDeleted',
	//   component: 'JDictSelectTag',
	//   componentProps:{
	//       dictCode:"isdelet"
	//    },
	// },
	{
		label: '所属省市',
		field: 'areaArray',
		component: 'JAreaLinkage',
		componentProps: {
			saveCode: 'all',
		},
		dynamicRules: ({model, schema}) => {
			return [{required: true, message: '请输入经营区域!'}];
		},
	},
	// TODO 主键隐藏字段，目前写死为ID
	{
		label: '',
		field: 'id',
		component: 'Input',
		show: false,
	},
];

// 高级查询数据
export const superQuerySchema = {
	name: {title: '充电站名称', order: 0, view: 'text', type: 'string'},
	stationType: {title: '站类型（0:城市公共, 1:高速站, 2:公交站，3：内部站 ，4：其他）', order: 1, view: 'number', type: 'number', dictCode: 'stationType'},
	operatorId: {title: '所属运营商', order: 2, view: 'number', type: 'number'},
	address: {title: '站地址', order: 3, view: 'text', type: 'string'},
	status: {title: '站状态', order: 4, view: 'number', type: 'number', dictCode: 'cdzzt'},
	totalPower: {title: '装机功率（千瓦）', order: 5, view: 'number', type: 'number'},
	dcChargers: {title: '直流桩数', order: 6, view: 'number', type: 'number'},
	acChargers: {title: '交流桩数', order: 7, view: 'number', type: 'number'},
	createTime: {title: '建档日期', order: 8, view: 'date', type: 'string'},
	longitude: {title: '经度', order: 9, view: 'number', type: 'number'},
	latitude: {title: '纬度', order: 10, view: 'number', type: 'number'},
	isDeleted: {title: '删除状态（0:未删除, 1:已删除）', order: 11, view: 'number', type: 'number', dictCode: 'isdelet'},
	areaArray: {title: '所属省市', order: 12, view: 'pca', type: 'string'},
};

/**
 * 流程表单调用这个方法获取formSchema
 * @param param
 */
export function getBpmFormSchema(_formData): FormSchema[] {
	// 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
	return formSchema;
}
